<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>

        function get_digit(num) {
            var res = 1; //次数 数字至少一位的 
            while (parseInt(num / 10) != 0) {
                num = parseInt(num / 10);
                res++
            }
            return res
        }

        // 这个工具用来判断一个数字是否是阿姆斯特数
        function is_amusitelang(num) {  // 153
            var data = num;
            var sum = 0
            // 先知道num是几位数  
            var len = get_digit(num);
            while (num > 0) {
                var digit = num % 10;   // 153 % 10 = 3   
                sum += digit ** len;
                num = parseInt(num / 10)     // 15 
            }
            if (sum == data) {
                return true
            }
        }

        for (var i = 1; i <= 1000; i++) {
            if (is_amusitelang(i)) {
                console.log(i)
            }
        }
    </script>
</body>

</html>